<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use common\models\FriendLink\FriendLink;
use common\models\LinkType\LinkType;
use kartik\file\FileInput;//图片上传
/* @var $this yii\web\View */
/* @var $model common\models\FriendLink\FriendLink */
/* @var $form yii\widgets\ActiveForm */
$leibie = ArrayHelper::map(LinkType::find()->all(), 'lid', 'typename');
?>
<style>
.kv-file-content img{ width: 100%!important; }
</style>
<div class="friend-link-form">
    <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data'],'id'=>'subform']); ?>
<div class="col-md-6" style="width:100%;">		
			<?= $form->field($model, 'lid')->dropDownList($leibie) ?>		
           <?= $form->field($model, 'link_name')->textInput(['maxlength' => true]) ?>
            <?php
            if(isset(json_decode($model->link_logo)->newname)){
                $img = json_decode($model->link_logo)->newname;
            }else{
                $img = $model->link_logo;
            }
            $siteRoot = Yii::$app->params['qtimg'];
            echo '<label class="control-label">照片(格式:98**98,以像在图片中部的半身像为佳)</label>;';
            echo FileInput::widget([
                'model' => $model,
                'attribute' => 'link_logo',
                'options' => ['accept' => 'image/*'],
                'pluginOptions' => [
                    'uploadExtraData' => [
                        'album_id' => 20,
                        'cat_id' => 'Nature'
                    ],
                    'initialPreview'=>[
                        !empty($img)?Html::img(Yii::$app->params['qtimg'].$img):null,
                    ],
                    'initialCaption'=> $img,
                    'maxFileCount' => 10,
                    "showUpload"=> false,
                ]
            ]);
            ?>		
	<?= $form->field($model, 'link_url')->textInput(['maxlength' => true]) ?>  

        <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>
    <?php ActiveForm::end(); ?>
</div>
